require 'iconv'
module WWW
  class Tkd
    class Express < ActiveRecord::Base
      def self.find_current_expresses
        find(:all,:conditions =>"not_exist=0 and (status_updated_at is null) or ((status_updated_at+INTERVAL 12 HOUR)<now())",:limit => 100)
      end
      def self.update_new_status agent_id,no
        list = find(:all,:conditions=>"agent_id="+agent_id.to_s+" and no_code='"+no+"'")
        list.each do|item|
          item.is_new=1
          item.status_updated_at=Time.now
          item.save
        end
      end
      def self.find_by_no agent_id,no
        list = find(:all,:conditions=>"agent_id="+agent_id.to_s+" and no_code='"+no+"'")
        if list.size()>0
          return list[0]
        end
        return nil
      end
    end
  end
end
